{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# PyCon 2019: Data Science Best Practices with pandas ([video](https://www.youtube.com/watch?v=dPwLlJkSHLo&list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y&index=36))\n",
    "\n",
    "### GitHub repository: https://github.com/justmarkham/pycon-2019-tutorial\n",
    "\n",
    "### Instructor: Kevin Markham\n",
    "\n",
    "- Website: https://www.dataschool.io\n",
    "- YouTube: https://www.youtube.com/dataschool\n",
    "- Patreon: https://www.patreon.com/dataschool\n",
    "- Twitter: https://twitter.com/justmarkham\n",
    "- GitHub: https://github.com/justmarkham"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. Introduction to the TED Talks dataset\n",
    "\n",
    "https://www.kaggle.com/rounakbanik/ted-talks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0.24.2'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "pd.__version__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "ted = pd.read_csv('ted.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>comments</th>\n",
       "      <th>description</th>\n",
       "      <th>duration</th>\n",
       "      <th>event</th>\n",
       "      <th>film_date</th>\n",
       "      <th>languages</th>\n",
       "      <th>main_speaker</th>\n",
       "      <th>name</th>\n",
       "      <th>num_speaker</th>\n",
       "      <th>published_date</th>\n",
       "      <th>ratings</th>\n",
       "      <th>related_talks</th>\n",
       "      <th>speaker_occupation</th>\n",
       "      <th>tags</th>\n",
       "      <th>title</th>\n",
       "      <th>url</th>\n",
       "      <th>views</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4553</td>\n",
       "      <td>Sir Ken Robinson makes an entertaining and pro...</td>\n",
       "      <td>1164</td>\n",
       "      <td>TED2006</td>\n",
       "      <td>1140825600</td>\n",
       "      <td>60</td>\n",
       "      <td>Ken Robinson</td>\n",
       "      <td>Ken Robinson: Do schools kill creativity?</td>\n",
       "      <td>1</td>\n",
       "      <td>1151367060</td>\n",
       "      <td>[{'id': 7, 'name': 'Funny', 'count': 19645}, {...</td>\n",
       "      <td>[{'id': 865, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Author/educator</td>\n",
       "      <td>['children', 'creativity', 'culture', 'dance',...</td>\n",
       "      <td>Do schools kill creativity?</td>\n",
       "      <td>https://www.ted.com/talks/ken_robinson_says_sc...</td>\n",
       "      <td>47227110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>265</td>\n",
       "      <td>With the same humor and humanity he exuded in ...</td>\n",
       "      <td>977</td>\n",
       "      <td>TED2006</td>\n",
       "      <td>1140825600</td>\n",
       "      <td>43</td>\n",
       "      <td>Al Gore</td>\n",
       "      <td>Al Gore: Averting the climate crisis</td>\n",
       "      <td>1</td>\n",
       "      <td>1151367060</td>\n",
       "      <td>[{'id': 7, 'name': 'Funny', 'count': 544}, {'i...</td>\n",
       "      <td>[{'id': 243, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Climate advocate</td>\n",
       "      <td>['alternative energy', 'cars', 'climate change...</td>\n",
       "      <td>Averting the climate crisis</td>\n",
       "      <td>https://www.ted.com/talks/al_gore_on_averting_...</td>\n",
       "      <td>3200520</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>124</td>\n",
       "      <td>New York Times columnist David Pogue takes aim...</td>\n",
       "      <td>1286</td>\n",
       "      <td>TED2006</td>\n",
       "      <td>1140739200</td>\n",
       "      <td>26</td>\n",
       "      <td>David Pogue</td>\n",
       "      <td>David Pogue: Simplicity sells</td>\n",
       "      <td>1</td>\n",
       "      <td>1151367060</td>\n",
       "      <td>[{'id': 7, 'name': 'Funny', 'count': 964}, {'i...</td>\n",
       "      <td>[{'id': 1725, 'hero': 'https://pe.tedcdn.com/i...</td>\n",
       "      <td>Technology columnist</td>\n",
       "      <td>['computers', 'entertainment', 'interface desi...</td>\n",
       "      <td>Simplicity sells</td>\n",
       "      <td>https://www.ted.com/talks/david_pogue_says_sim...</td>\n",
       "      <td>1636292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>200</td>\n",
       "      <td>In an emotionally charged talk, MacArthur-winn...</td>\n",
       "      <td>1116</td>\n",
       "      <td>TED2006</td>\n",
       "      <td>1140912000</td>\n",
       "      <td>35</td>\n",
       "      <td>Majora Carter</td>\n",
       "      <td>Majora Carter: Greening the ghetto</td>\n",
       "      <td>1</td>\n",
       "      <td>1151367060</td>\n",
       "      <td>[{'id': 3, 'name': 'Courageous', 'count': 760}...</td>\n",
       "      <td>[{'id': 1041, 'hero': 'https://pe.tedcdn.com/i...</td>\n",
       "      <td>Activist for environmental justice</td>\n",
       "      <td>['MacArthur grant', 'activism', 'business', 'c...</td>\n",
       "      <td>Greening the ghetto</td>\n",
       "      <td>https://www.ted.com/talks/majora_carter_s_tale...</td>\n",
       "      <td>1697550</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>593</td>\n",
       "      <td>You've never seen data presented like this. Wi...</td>\n",
       "      <td>1190</td>\n",
       "      <td>TED2006</td>\n",
       "      <td>1140566400</td>\n",
       "      <td>48</td>\n",
       "      <td>Hans Rosling</td>\n",
       "      <td>Hans Rosling: The best stats you've ever seen</td>\n",
       "      <td>1</td>\n",
       "      <td>1151440680</td>\n",
       "      <td>[{'id': 9, 'name': 'Ingenious', 'count': 3202}...</td>\n",
       "      <td>[{'id': 2056, 'hero': 'https://pe.tedcdn.com/i...</td>\n",
       "      <td>Global health expert; data visionary</td>\n",
       "      <td>['Africa', 'Asia', 'Google', 'demo', 'economic...</td>\n",
       "      <td>The best stats you've ever seen</td>\n",
       "      <td>https://www.ted.com/talks/hans_rosling_shows_t...</td>\n",
       "      <td>12005869</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   comments                                        description  duration  \\\n",
       "0      4553  Sir Ken Robinson makes an entertaining and pro...      1164   \n",
       "1       265  With the same humor and humanity he exuded in ...       977   \n",
       "2       124  New York Times columnist David Pogue takes aim...      1286   \n",
       "3       200  In an emotionally charged talk, MacArthur-winn...      1116   \n",
       "4       593  You've never seen data presented like this. Wi...      1190   \n",
       "\n",
       "     event   film_date  languages   main_speaker  \\\n",
       "0  TED2006  1140825600         60   Ken Robinson   \n",
       "1  TED2006  1140825600         43        Al Gore   \n",
       "2  TED2006  1140739200         26    David Pogue   \n",
       "3  TED2006  1140912000         35  Majora Carter   \n",
       "4  TED2006  1140566400         48   Hans Rosling   \n",
       "\n",
       "                                            name  num_speaker  published_date  \\\n",
       "0      Ken Robinson: Do schools kill creativity?            1      1151367060   \n",
       "1           Al Gore: Averting the climate crisis            1      1151367060   \n",
       "2                  David Pogue: Simplicity sells            1      1151367060   \n",
       "3             Majora Carter: Greening the ghetto            1      1151367060   \n",
       "4  Hans Rosling: The best stats you've ever seen            1      1151440680   \n",
       "\n",
       "                                             ratings  \\\n",
       "0  [{'id': 7, 'name': 'Funny', 'count': 19645}, {...   \n",
       "1  [{'id': 7, 'name': 'Funny', 'count': 544}, {'i...   \n",
       "2  [{'id': 7, 'name': 'Funny', 'count': 964}, {'i...   \n",
       "3  [{'id': 3, 'name': 'Courageous', 'count': 760}...   \n",
       "4  [{'id': 9, 'name': 'Ingenious', 'count': 3202}...   \n",
       "\n",
       "                                       related_talks  \\\n",
       "0  [{'id': 865, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "1  [{'id': 243, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "2  [{'id': 1725, 'hero': 'https://pe.tedcdn.com/i...   \n",
       "3  [{'id': 1041, 'hero': 'https://pe.tedcdn.com/i...   \n",
       "4  [{'id': 2056, 'hero': 'https://pe.tedcdn.com/i...   \n",
       "\n",
       "                     speaker_occupation  \\\n",
       "0                       Author/educator   \n",
       "1                      Climate advocate   \n",
       "2                  Technology columnist   \n",
       "3    Activist for environmental justice   \n",
       "4  Global health expert; data visionary   \n",
       "\n",
       "                                                tags  \\\n",
       "0  ['children', 'creativity', 'culture', 'dance',...   \n",
       "1  ['alternative energy', 'cars', 'climate change...   \n",
       "2  ['computers', 'entertainment', 'interface desi...   \n",
       "3  ['MacArthur grant', 'activism', 'business', 'c...   \n",
       "4  ['Africa', 'Asia', 'Google', 'demo', 'economic...   \n",
       "\n",
       "                             title  \\\n",
       "0      Do schools kill creativity?   \n",
       "1      Averting the climate crisis   \n",
       "2                 Simplicity sells   \n",
       "3              Greening the ghetto   \n",
       "4  The best stats you've ever seen   \n",
       "\n",
       "                                                 url     views  \n",
       "0  https://www.ted.com/talks/ken_robinson_says_sc...  47227110  \n",
       "1  https://www.ted.com/talks/al_gore_on_averting_...   3200520  \n",
       "2  https://www.ted.com/talks/david_pogue_says_sim...   1636292  \n",
       "3  https://www.ted.com/talks/majora_carter_s_tale...   1697550  \n",
       "4  https://www.ted.com/talks/hans_rosling_shows_t...  12005869  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# each row represents a single talk\n",
    "ted.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2550, 17)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# rows, columns\n",
    "ted.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "comments               int64\n",
       "description           object\n",
       "duration               int64\n",
       "event                 object\n",
       "film_date              int64\n",
       "languages              int64\n",
       "main_speaker          object\n",
       "name                  object\n",
       "num_speaker            int64\n",
       "published_date         int64\n",
       "ratings               object\n",
       "related_talks         object\n",
       "speaker_occupation    object\n",
       "tags                  object\n",
       "title                 object\n",
       "url                   object\n",
       "views                  int64\n",
       "dtype: object"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# object columns are usually strings, but can also be arbitrary Python objects (lists, dictionaries)\n",
    "ted.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "comments              0\n",
       "description           0\n",
       "duration              0\n",
       "event                 0\n",
       "film_date             0\n",
       "languages             0\n",
       "main_speaker          0\n",
       "name                  0\n",
       "num_speaker           0\n",
       "published_date        0\n",
       "ratings               0\n",
       "related_talks         0\n",
       "speaker_occupation    6\n",
       "tags                  0\n",
       "title                 0\n",
       "url                   0\n",
       "views                 0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# count the number of missing values in each column\n",
    "ted.isna().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. Which talks provoke the most online discussion?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>comments</th>\n",
       "      <th>description</th>\n",
       "      <th>duration</th>\n",
       "      <th>event</th>\n",
       "      <th>film_date</th>\n",
       "      <th>languages</th>\n",
       "      <th>main_speaker</th>\n",
       "      <th>name</th>\n",
       "      <th>num_speaker</th>\n",
       "      <th>published_date</th>\n",
       "      <th>ratings</th>\n",
       "      <th>related_talks</th>\n",
       "      <th>speaker_occupation</th>\n",
       "      <th>tags</th>\n",
       "      <th>title</th>\n",
       "      <th>url</th>\n",
       "      <th>views</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1787</th>\n",
       "      <td>2673</td>\n",
       "      <td>Our consciousness is a fundamental aspect of o...</td>\n",
       "      <td>1117</td>\n",
       "      <td>TED2014</td>\n",
       "      <td>1395100800</td>\n",
       "      <td>33</td>\n",
       "      <td>David Chalmers</td>\n",
       "      <td>David Chalmers: How do you explain consciousness?</td>\n",
       "      <td>1</td>\n",
       "      <td>1405350484</td>\n",
       "      <td>[{'id': 25, 'name': 'OK', 'count': 280}, {'id'...</td>\n",
       "      <td>[{'id': 1308, 'hero': 'https://pe.tedcdn.com/i...</td>\n",
       "      <td>Philosopher</td>\n",
       "      <td>['brain', 'consciousness', 'neuroscience', 'ph...</td>\n",
       "      <td>How do you explain consciousness?</td>\n",
       "      <td>https://www.ted.com/talks/david_chalmers_how_d...</td>\n",
       "      <td>2162764</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>201</th>\n",
       "      <td>2877</td>\n",
       "      <td>Jill Bolte Taylor got a research opportunity f...</td>\n",
       "      <td>1099</td>\n",
       "      <td>TED2008</td>\n",
       "      <td>1204070400</td>\n",
       "      <td>49</td>\n",
       "      <td>Jill Bolte Taylor</td>\n",
       "      <td>Jill Bolte Taylor: My stroke of insight</td>\n",
       "      <td>1</td>\n",
       "      <td>1205284200</td>\n",
       "      <td>[{'id': 22, 'name': 'Fascinating', 'count': 14...</td>\n",
       "      <td>[{'id': 184, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Neuroanatomist</td>\n",
       "      <td>['biology', 'brain', 'consciousness', 'global ...</td>\n",
       "      <td>My stroke of insight</td>\n",
       "      <td>https://www.ted.com/talks/jill_bolte_taylor_s_...</td>\n",
       "      <td>21190883</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>644</th>\n",
       "      <td>3356</td>\n",
       "      <td>Questions of good and evil, right and wrong ar...</td>\n",
       "      <td>1386</td>\n",
       "      <td>TED2010</td>\n",
       "      <td>1265846400</td>\n",
       "      <td>39</td>\n",
       "      <td>Sam Harris</td>\n",
       "      <td>Sam Harris: Science can answer moral questions</td>\n",
       "      <td>1</td>\n",
       "      <td>1269249180</td>\n",
       "      <td>[{'id': 8, 'name': 'Informative', 'count': 923...</td>\n",
       "      <td>[{'id': 666, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Neuroscientist, philosopher</td>\n",
       "      <td>['culture', 'evolutionary psychology', 'global...</td>\n",
       "      <td>Science can answer moral questions</td>\n",
       "      <td>https://www.ted.com/talks/sam_harris_science_c...</td>\n",
       "      <td>3433437</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4553</td>\n",
       "      <td>Sir Ken Robinson makes an entertaining and pro...</td>\n",
       "      <td>1164</td>\n",
       "      <td>TED2006</td>\n",
       "      <td>1140825600</td>\n",
       "      <td>60</td>\n",
       "      <td>Ken Robinson</td>\n",
       "      <td>Ken Robinson: Do schools kill creativity?</td>\n",
       "      <td>1</td>\n",
       "      <td>1151367060</td>\n",
       "      <td>[{'id': 7, 'name': 'Funny', 'count': 19645}, {...</td>\n",
       "      <td>[{'id': 865, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Author/educator</td>\n",
       "      <td>['children', 'creativity', 'culture', 'dance',...</td>\n",
       "      <td>Do schools kill creativity?</td>\n",
       "      <td>https://www.ted.com/talks/ken_robinson_says_sc...</td>\n",
       "      <td>47227110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>6404</td>\n",
       "      <td>Richard Dawkins urges all atheists to openly s...</td>\n",
       "      <td>1750</td>\n",
       "      <td>TED2002</td>\n",
       "      <td>1012608000</td>\n",
       "      <td>42</td>\n",
       "      <td>Richard Dawkins</td>\n",
       "      <td>Richard Dawkins: Militant atheism</td>\n",
       "      <td>1</td>\n",
       "      <td>1176689220</td>\n",
       "      <td>[{'id': 3, 'name': 'Courageous', 'count': 3236...</td>\n",
       "      <td>[{'id': 86, 'hero': 'https://pe.tedcdn.com/ima...</td>\n",
       "      <td>Evolutionary biologist</td>\n",
       "      <td>['God', 'atheism', 'culture', 'religion', 'sci...</td>\n",
       "      <td>Militant atheism</td>\n",
       "      <td>https://www.ted.com/talks/richard_dawkins_on_m...</td>\n",
       "      <td>4374792</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      comments                                        description  duration  \\\n",
       "1787      2673  Our consciousness is a fundamental aspect of o...      1117   \n",
       "201       2877  Jill Bolte Taylor got a research opportunity f...      1099   \n",
       "644       3356  Questions of good and evil, right and wrong ar...      1386   \n",
       "0         4553  Sir Ken Robinson makes an entertaining and pro...      1164   \n",
       "96        6404  Richard Dawkins urges all atheists to openly s...      1750   \n",
       "\n",
       "        event   film_date  languages       main_speaker  \\\n",
       "1787  TED2014  1395100800         33     David Chalmers   \n",
       "201   TED2008  1204070400         49  Jill Bolte Taylor   \n",
       "644   TED2010  1265846400         39         Sam Harris   \n",
       "0     TED2006  1140825600         60       Ken Robinson   \n",
       "96    TED2002  1012608000         42    Richard Dawkins   \n",
       "\n",
       "                                                   name  num_speaker  \\\n",
       "1787  David Chalmers: How do you explain consciousness?            1   \n",
       "201             Jill Bolte Taylor: My stroke of insight            1   \n",
       "644      Sam Harris: Science can answer moral questions            1   \n",
       "0             Ken Robinson: Do schools kill creativity?            1   \n",
       "96                    Richard Dawkins: Militant atheism            1   \n",
       "\n",
       "      published_date                                            ratings  \\\n",
       "1787      1405350484  [{'id': 25, 'name': 'OK', 'count': 280}, {'id'...   \n",
       "201       1205284200  [{'id': 22, 'name': 'Fascinating', 'count': 14...   \n",
       "644       1269249180  [{'id': 8, 'name': 'Informative', 'count': 923...   \n",
       "0         1151367060  [{'id': 7, 'name': 'Funny', 'count': 19645}, {...   \n",
       "96        1176689220  [{'id': 3, 'name': 'Courageous', 'count': 3236...   \n",
       "\n",
       "                                          related_talks  \\\n",
       "1787  [{'id': 1308, 'hero': 'https://pe.tedcdn.com/i...   \n",
       "201   [{'id': 184, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "644   [{'id': 666, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "0     [{'id': 865, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "96    [{'id': 86, 'hero': 'https://pe.tedcdn.com/ima...   \n",
       "\n",
       "               speaker_occupation  \\\n",
       "1787                  Philosopher   \n",
       "201                Neuroanatomist   \n",
       "644   Neuroscientist, philosopher   \n",
       "0                 Author/educator   \n",
       "96         Evolutionary biologist   \n",
       "\n",
       "                                                   tags  \\\n",
       "1787  ['brain', 'consciousness', 'neuroscience', 'ph...   \n",
       "201   ['biology', 'brain', 'consciousness', 'global ...   \n",
       "644   ['culture', 'evolutionary psychology', 'global...   \n",
       "0     ['children', 'creativity', 'culture', 'dance',...   \n",
       "96    ['God', 'atheism', 'culture', 'religion', 'sci...   \n",
       "\n",
       "                                   title  \\\n",
       "1787   How do you explain consciousness?   \n",
       "201                 My stroke of insight   \n",
       "644   Science can answer moral questions   \n",
       "0            Do schools kill creativity?   \n",
       "96                      Militant atheism   \n",
       "\n",
       "                                                    url     views  \n",
       "1787  https://www.ted.com/talks/david_chalmers_how_d...   2162764  \n",
       "201   https://www.ted.com/talks/jill_bolte_taylor_s_...  21190883  \n",
       "644   https://www.ted.com/talks/sam_harris_science_c...   3433437  \n",
       "0     https://www.ted.com/talks/ken_robinson_says_sc...  47227110  \n",
       "96    https://www.ted.com/talks/richard_dawkins_on_m...   4374792  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# sort by the number of first-level comments, though this is biased in favor of older talks\n",
    "ted.sort_values('comments').tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# correct for this bias by calculating the number of comments per view\n",
    "ted['comments_per_view'] = ted.comments / ted.views"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>comments</th>\n",
       "      <th>description</th>\n",
       "      <th>duration</th>\n",
       "      <th>event</th>\n",
       "      <th>film_date</th>\n",
       "      <th>languages</th>\n",
       "      <th>main_speaker</th>\n",
       "      <th>name</th>\n",
       "      <th>num_speaker</th>\n",
       "      <th>published_date</th>\n",
       "      <th>ratings</th>\n",
       "      <th>related_talks</th>\n",
       "      <th>speaker_occupation</th>\n",
       "      <th>tags</th>\n",
       "      <th>title</th>\n",
       "      <th>url</th>\n",
       "      <th>views</th>\n",
       "      <th>comments_per_view</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>954</th>\n",
       "      <td>2492</td>\n",
       "      <td>Janet Echelman found her true voice as an arti...</td>\n",
       "      <td>566</td>\n",
       "      <td>TED2011</td>\n",
       "      <td>1299110400</td>\n",
       "      <td>35</td>\n",
       "      <td>Janet Echelman</td>\n",
       "      <td>Janet Echelman: Taking imagination seriously</td>\n",
       "      <td>1</td>\n",
       "      <td>1307489760</td>\n",
       "      <td>[{'id': 23, 'name': 'Jaw-dropping', 'count': 3...</td>\n",
       "      <td>[{'id': 453, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Artist</td>\n",
       "      <td>['art', 'cities', 'culture', 'data', 'design',...</td>\n",
       "      <td>Taking imagination seriously</td>\n",
       "      <td>https://www.ted.com/talks/janet_echelman</td>\n",
       "      <td>1832930</td>\n",
       "      <td>0.001360</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>694</th>\n",
       "      <td>1502</td>\n",
       "      <td>Filmmaker Sharmeen Obaid-Chinoy takes on a ter...</td>\n",
       "      <td>489</td>\n",
       "      <td>TED2010</td>\n",
       "      <td>1265760000</td>\n",
       "      <td>32</td>\n",
       "      <td>Sharmeen Obaid-Chinoy</td>\n",
       "      <td>Sharmeen Obaid-Chinoy: Inside a school for sui...</td>\n",
       "      <td>1</td>\n",
       "      <td>1274865960</td>\n",
       "      <td>[{'id': 23, 'name': 'Jaw-dropping', 'count': 3...</td>\n",
       "      <td>[{'id': 171, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Filmmaker</td>\n",
       "      <td>['TED Fellows', 'children', 'culture', 'film',...</td>\n",
       "      <td>Inside a school for suicide bombers</td>\n",
       "      <td>https://www.ted.com/talks/sharmeen_obaid_chino...</td>\n",
       "      <td>1057238</td>\n",
       "      <td>0.001421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>6404</td>\n",
       "      <td>Richard Dawkins urges all atheists to openly s...</td>\n",
       "      <td>1750</td>\n",
       "      <td>TED2002</td>\n",
       "      <td>1012608000</td>\n",
       "      <td>42</td>\n",
       "      <td>Richard Dawkins</td>\n",
       "      <td>Richard Dawkins: Militant atheism</td>\n",
       "      <td>1</td>\n",
       "      <td>1176689220</td>\n",
       "      <td>[{'id': 3, 'name': 'Courageous', 'count': 3236...</td>\n",
       "      <td>[{'id': 86, 'hero': 'https://pe.tedcdn.com/ima...</td>\n",
       "      <td>Evolutionary biologist</td>\n",
       "      <td>['God', 'atheism', 'culture', 'religion', 'sci...</td>\n",
       "      <td>Militant atheism</td>\n",
       "      <td>https://www.ted.com/talks/richard_dawkins_on_m...</td>\n",
       "      <td>4374792</td>\n",
       "      <td>0.001464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>803</th>\n",
       "      <td>834</td>\n",
       "      <td>David Bismark demos a new system for voting th...</td>\n",
       "      <td>422</td>\n",
       "      <td>TEDGlobal 2010</td>\n",
       "      <td>1279065600</td>\n",
       "      <td>36</td>\n",
       "      <td>David Bismark</td>\n",
       "      <td>David Bismark: E-voting without fraud</td>\n",
       "      <td>1</td>\n",
       "      <td>1288685640</td>\n",
       "      <td>[{'id': 25, 'name': 'OK', 'count': 111}, {'id'...</td>\n",
       "      <td>[{'id': 803, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Voting system designer</td>\n",
       "      <td>['culture', 'democracy', 'design', 'global iss...</td>\n",
       "      <td>E-voting without fraud</td>\n",
       "      <td>https://www.ted.com/talks/david_bismark_e_voti...</td>\n",
       "      <td>543551</td>\n",
       "      <td>0.001534</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>744</th>\n",
       "      <td>649</td>\n",
       "      <td>Hours before New York lawmakers rejected a key...</td>\n",
       "      <td>453</td>\n",
       "      <td>New York State Senate</td>\n",
       "      <td>1259712000</td>\n",
       "      <td>0</td>\n",
       "      <td>Diane J. Savino</td>\n",
       "      <td>Diane J. Savino: The case for same-sex marriage</td>\n",
       "      <td>1</td>\n",
       "      <td>1282062180</td>\n",
       "      <td>[{'id': 25, 'name': 'OK', 'count': 100}, {'id'...</td>\n",
       "      <td>[{'id': 217, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Senator</td>\n",
       "      <td>['God', 'LGBT', 'culture', 'government', 'law'...</td>\n",
       "      <td>The case for same-sex marriage</td>\n",
       "      <td>https://www.ted.com/talks/diane_j_savino_the_c...</td>\n",
       "      <td>292395</td>\n",
       "      <td>0.002220</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     comments                                        description  duration  \\\n",
       "954      2492  Janet Echelman found her true voice as an arti...       566   \n",
       "694      1502  Filmmaker Sharmeen Obaid-Chinoy takes on a ter...       489   \n",
       "96       6404  Richard Dawkins urges all atheists to openly s...      1750   \n",
       "803       834  David Bismark demos a new system for voting th...       422   \n",
       "744       649  Hours before New York lawmakers rejected a key...       453   \n",
       "\n",
       "                     event   film_date  languages           main_speaker  \\\n",
       "954                TED2011  1299110400         35         Janet Echelman   \n",
       "694                TED2010  1265760000         32  Sharmeen Obaid-Chinoy   \n",
       "96                 TED2002  1012608000         42        Richard Dawkins   \n",
       "803         TEDGlobal 2010  1279065600         36          David Bismark   \n",
       "744  New York State Senate  1259712000          0        Diane J. Savino   \n",
       "\n",
       "                                                  name  num_speaker  \\\n",
       "954       Janet Echelman: Taking imagination seriously            1   \n",
       "694  Sharmeen Obaid-Chinoy: Inside a school for sui...            1   \n",
       "96                   Richard Dawkins: Militant atheism            1   \n",
       "803              David Bismark: E-voting without fraud            1   \n",
       "744    Diane J. Savino: The case for same-sex marriage            1   \n",
       "\n",
       "     published_date                                            ratings  \\\n",
       "954      1307489760  [{'id': 23, 'name': 'Jaw-dropping', 'count': 3...   \n",
       "694      1274865960  [{'id': 23, 'name': 'Jaw-dropping', 'count': 3...   \n",
       "96       1176689220  [{'id': 3, 'name': 'Courageous', 'count': 3236...   \n",
       "803      1288685640  [{'id': 25, 'name': 'OK', 'count': 111}, {'id'...   \n",
       "744      1282062180  [{'id': 25, 'name': 'OK', 'count': 100}, {'id'...   \n",
       "\n",
       "                                         related_talks  \\\n",
       "954  [{'id': 453, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "694  [{'id': 171, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "96   [{'id': 86, 'hero': 'https://pe.tedcdn.com/ima...   \n",
       "803  [{'id': 803, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "744  [{'id': 217, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "\n",
       "         speaker_occupation  \\\n",
       "954                  Artist   \n",
       "694               Filmmaker   \n",
       "96   Evolutionary biologist   \n",
       "803  Voting system designer   \n",
       "744                 Senator   \n",
       "\n",
       "                                                  tags  \\\n",
       "954  ['art', 'cities', 'culture', 'data', 'design',...   \n",
       "694  ['TED Fellows', 'children', 'culture', 'film',...   \n",
       "96   ['God', 'atheism', 'culture', 'religion', 'sci...   \n",
       "803  ['culture', 'democracy', 'design', 'global iss...   \n",
       "744  ['God', 'LGBT', 'culture', 'government', 'law'...   \n",
       "\n",
       "                                   title  \\\n",
       "954         Taking imagination seriously   \n",
       "694  Inside a school for suicide bombers   \n",
       "96                      Militant atheism   \n",
       "803               E-voting without fraud   \n",
       "744       The case for same-sex marriage   \n",
       "\n",
       "                                                   url    views  \\\n",
       "954           https://www.ted.com/talks/janet_echelman  1832930   \n",
       "694  https://www.ted.com/talks/sharmeen_obaid_chino...  1057238   \n",
       "96   https://www.ted.com/talks/richard_dawkins_on_m...  4374792   \n",
       "803  https://www.ted.com/talks/david_bismark_e_voti...   543551   \n",
       "744  https://www.ted.com/talks/diane_j_savino_the_c...   292395   \n",
       "\n",
       "     comments_per_view  \n",
       "954           0.001360  \n",
       "694           0.001421  \n",
       "96            0.001464  \n",
       "803           0.001534  \n",
       "744           0.002220  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# interpretation: for every view of the same-sex marriage talk, there are 0.002 comments\n",
    "ted.sort_values('comments_per_view').tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# make this more interpretable by inverting the calculation\n",
    "ted['views_per_comment'] = ted.views / ted.comments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>comments</th>\n",
       "      <th>description</th>\n",
       "      <th>duration</th>\n",
       "      <th>event</th>\n",
       "      <th>film_date</th>\n",
       "      <th>languages</th>\n",
       "      <th>main_speaker</th>\n",
       "      <th>name</th>\n",
       "      <th>num_speaker</th>\n",
       "      <th>published_date</th>\n",
       "      <th>ratings</th>\n",
       "      <th>related_talks</th>\n",
       "      <th>speaker_occupation</th>\n",
       "      <th>tags</th>\n",
       "      <th>title</th>\n",
       "      <th>url</th>\n",
       "      <th>views</th>\n",
       "      <th>comments_per_view</th>\n",
       "      <th>views_per_comment</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>744</th>\n",
       "      <td>649</td>\n",
       "      <td>Hours before New York lawmakers rejected a key...</td>\n",
       "      <td>453</td>\n",
       "      <td>New York State Senate</td>\n",
       "      <td>1259712000</td>\n",
       "      <td>0</td>\n",
       "      <td>Diane J. Savino</td>\n",
       "      <td>Diane J. Savino: The case for same-sex marriage</td>\n",
       "      <td>1</td>\n",
       "      <td>1282062180</td>\n",
       "      <td>[{'id': 25, 'name': 'OK', 'count': 100}, {'id'...</td>\n",
       "      <td>[{'id': 217, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Senator</td>\n",
       "      <td>['God', 'LGBT', 'culture', 'government', 'law'...</td>\n",
       "      <td>The case for same-sex marriage</td>\n",
       "      <td>https://www.ted.com/talks/diane_j_savino_the_c...</td>\n",
       "      <td>292395</td>\n",
       "      <td>0.002220</td>\n",
       "      <td>450.531587</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>803</th>\n",
       "      <td>834</td>\n",
       "      <td>David Bismark demos a new system for voting th...</td>\n",
       "      <td>422</td>\n",
       "      <td>TEDGlobal 2010</td>\n",
       "      <td>1279065600</td>\n",
       "      <td>36</td>\n",
       "      <td>David Bismark</td>\n",
       "      <td>David Bismark: E-voting without fraud</td>\n",
       "      <td>1</td>\n",
       "      <td>1288685640</td>\n",
       "      <td>[{'id': 25, 'name': 'OK', 'count': 111}, {'id'...</td>\n",
       "      <td>[{'id': 803, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Voting system designer</td>\n",
       "      <td>['culture', 'democracy', 'design', 'global iss...</td>\n",
       "      <td>E-voting without fraud</td>\n",
       "      <td>https://www.ted.com/talks/david_bismark_e_voti...</td>\n",
       "      <td>543551</td>\n",
       "      <td>0.001534</td>\n",
       "      <td>651.739808</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>6404</td>\n",
       "      <td>Richard Dawkins urges all atheists to openly s...</td>\n",
       "      <td>1750</td>\n",
       "      <td>TED2002</td>\n",
       "      <td>1012608000</td>\n",
       "      <td>42</td>\n",
       "      <td>Richard Dawkins</td>\n",
       "      <td>Richard Dawkins: Militant atheism</td>\n",
       "      <td>1</td>\n",
       "      <td>1176689220</td>\n",
       "      <td>[{'id': 3, 'name': 'Courageous', 'count': 3236...</td>\n",
       "      <td>[{'id': 86, 'hero': 'https://pe.tedcdn.com/ima...</td>\n",
       "      <td>Evolutionary biologist</td>\n",
       "      <td>['God', 'atheism', 'culture', 'religion', 'sci...</td>\n",
       "      <td>Militant atheism</td>\n",
       "      <td>https://www.ted.com/talks/richard_dawkins_on_m...</td>\n",
       "      <td>4374792</td>\n",
       "      <td>0.001464</td>\n",
       "      <td>683.134291</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>694</th>\n",
       "      <td>1502</td>\n",
       "      <td>Filmmaker Sharmeen Obaid-Chinoy takes on a ter...</td>\n",
       "      <td>489</td>\n",
       "      <td>TED2010</td>\n",
       "      <td>1265760000</td>\n",
       "      <td>32</td>\n",
       "      <td>Sharmeen Obaid-Chinoy</td>\n",
       "      <td>Sharmeen Obaid-Chinoy: Inside a school for sui...</td>\n",
       "      <td>1</td>\n",
       "      <td>1274865960</td>\n",
       "      <td>[{'id': 23, 'name': 'Jaw-dropping', 'count': 3...</td>\n",
       "      <td>[{'id': 171, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Filmmaker</td>\n",
       "      <td>['TED Fellows', 'children', 'culture', 'film',...</td>\n",
       "      <td>Inside a school for suicide bombers</td>\n",
       "      <td>https://www.ted.com/talks/sharmeen_obaid_chino...</td>\n",
       "      <td>1057238</td>\n",
       "      <td>0.001421</td>\n",
       "      <td>703.886818</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>954</th>\n",
       "      <td>2492</td>\n",
       "      <td>Janet Echelman found her true voice as an arti...</td>\n",
       "      <td>566</td>\n",
       "      <td>TED2011</td>\n",
       "      <td>1299110400</td>\n",
       "      <td>35</td>\n",
       "      <td>Janet Echelman</td>\n",
       "      <td>Janet Echelman: Taking imagination seriously</td>\n",
       "      <td>1</td>\n",
       "      <td>1307489760</td>\n",
       "      <td>[{'id': 23, 'name': 'Jaw-dropping', 'count': 3...</td>\n",
       "      <td>[{'id': 453, 'hero': 'https://pe.tedcdn.com/im...</td>\n",
       "      <td>Artist</td>\n",
       "      <td>['art', 'cities', 'culture', 'data', 'design',...</td>\n",
       "      <td>Taking imagination seriously</td>\n",
       "      <td>https://www.ted.com/talks/janet_echelman</td>\n",
       "      <td>1832930</td>\n",
       "      <td>0.001360</td>\n",
       "      <td>735.525682</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     comments                                        description  duration  \\\n",
       "744       649  Hours before New York lawmakers rejected a key...       453   \n",
       "803       834  David Bismark demos a new system for voting th...       422   \n",
       "96       6404  Richard Dawkins urges all atheists to openly s...      1750   \n",
       "694      1502  Filmmaker Sharmeen Obaid-Chinoy takes on a ter...       489   \n",
       "954      2492  Janet Echelman found her true voice as an arti...       566   \n",
       "\n",
       "                     event   film_date  languages           main_speaker  \\\n",
       "744  New York State Senate  1259712000          0        Diane J. Savino   \n",
       "803         TEDGlobal 2010  1279065600         36          David Bismark   \n",
       "96                 TED2002  1012608000         42        Richard Dawkins   \n",
       "694                TED2010  1265760000         32  Sharmeen Obaid-Chinoy   \n",
       "954                TED2011  1299110400         35         Janet Echelman   \n",
       "\n",
       "                                                  name  num_speaker  \\\n",
       "744    Diane J. Savino: The case for same-sex marriage            1   \n",
       "803              David Bismark: E-voting without fraud            1   \n",
       "96                   Richard Dawkins: Militant atheism            1   \n",
       "694  Sharmeen Obaid-Chinoy: Inside a school for sui...            1   \n",
       "954       Janet Echelman: Taking imagination seriously            1   \n",
       "\n",
       "     published_date                                            ratings  \\\n",
       "744      1282062180  [{'id': 25, 'name': 'OK', 'count': 100}, {'id'...   \n",
       "803      1288685640  [{'id': 25, 'name': 'OK', 'count': 111}, {'id'...   \n",
       "96       1176689220  [{'id': 3, 'name': 'Courageous', 'count': 3236...   \n",
       "694      1274865960  [{'id': 23, 'name': 'Jaw-dropping', 'count': 3...   \n",
       "954      1307489760  [{'id': 23, 'name': 'Jaw-dropping', 'count': 3...   \n",
       "\n",
       "                                         related_talks  \\\n",
       "744  [{'id': 217, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "803  [{'id': 803, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "96   [{'id': 86, 'hero': 'https://pe.tedcdn.com/ima...   \n",
       "694  [{'id': 171, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "954  [{'id': 453, 'hero': 'https://pe.tedcdn.com/im...   \n",
       "\n",
       "         speaker_occupation  \\\n",
       "744                 Senator   \n",
       "803  Voting system designer   \n",
       "96   Evolutionary biologist   \n",
       "694               Filmmaker   \n",
       "954                  Artist   \n",
       "\n",
       "                                                  tags  \\\n",
       "744  ['God', 'LGBT', 'culture', 'government', 'law'...   \n",
       "803  ['culture', 'democracy', 'design', 'global iss...   \n",
       "96   ['God', 'atheism', 'culture', 'religion', 'sci...   \n",
       "694  ['TED Fellows', 'children', 'culture', 'film',...   \n",
       "954  ['art', 'cities', 'culture', 'data', 'design',...   \n",
       "\n",
       "                                   title  \\\n",
       "744       The case for same-sex marriage   \n",
       "803               E-voting without fraud   \n",
       "96                      Militant atheism   \n",
       "694  Inside a school for suicide bombers   \n",
       "954         Taking imagination seriously   \n",
       "\n",
       "                                                   url    views  \\\n",
       "744  https://www.ted.com/talks/diane_j_savino_the_c...   292395   \n",
       "803  https://www.ted.com/talks/david_bismark_e_voti...   543551   \n",
       "96   https://www.ted.com/talks/richard_dawkins_on_m...  4374792   \n",
       "694  https://www.ted.com/talks/sharmeen_obaid_chino...  1057238   \n",
       "954           https://www.ted.com/talks/janet_echelman  1832930   \n",
       "\n",
       "     comments_per_view  views_per_comment  \n",
       "744           0.002220         450.531587  \n",
       "803           0.001534         651.739808  \n",
       "96            0.001464         683.134291  \n",
       "694           0.001421         703.886818  \n",
       "954           0.001360         735.525682  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# interpretation: 1 out of every 450 people leave a comment\n",
    "ted.sort_values('views_per_comment').head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lessons:\n",
    "\n",
    "1. Consider the limitations and biases of your data when analyzing it\n",
    "2. Make your results understandable"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. Visualize the distribution of comments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1098cc0f0>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAD8CAYAAACVZ8iyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xl8VPW9//HXh13cAEVFRKGKVbq4UbX11tYNUGzRtnrtr7fS1tbeW3tve9t7W6y1WGvV1gKtrVW5SkXrblWooBgWQZEt7DuJECAEEiArhGyT7++PORNmJjOTmclMZiZ5Px+PPDLzne9MvufkzPmc73rMOYeIiHRt3TJdABERyTwFAxERUTAQEREFAxERQcFARERQMBARERQMREQEBQMREUHBQEREgB6ZLkAsJ598shs6dGimiyEiklNWrlx5wDk3MJH3ZHUwGDp0KPn5+ZkuhohITjGznYm+R81EIiKiYCAiIgoGIiKCgoGIiKBgICIiKBiIiAgKBiIiQicLBvlF5WzZV53pYoiI5JysnnSWqK89sQSAoofHZrgkIiK5pVPVDEREJDkKBiIiomAgIiIKBiIigoKBiIigYCAiIigYiIgICgYiIkKcwcDM+pnZa2a2xcw2m9lnzWyAmeWZWYH3u7+X18zsUTMrNLN1ZnZx0OeM9/IXmNn4d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N6Zhz1d4Zy7GLgeuMvMroyRt6vtm4Bo291Z98fjwNnAhcBeYJKX3qn3g5kdB/wD+LFzrjpW1ghpnXk/pP14yNZgUAwMCXp+BlCSobKknXOuxPtdBryBv4pXGmj+8X6Xedk7+75JdLs75f5wzpU653zOuWbg//AfE9CJ94OZ9cR/AnzeOfe6l9zljodI+6EjjodsDQYrgOFmNszMegG3ATMzXKa0MLNjzez4wGNgFLAB//YGRkKMB2Z4j2cCt3ujKS4HqgLV6E4i0e2eA4wys/5e1XmUl5bTwvqBbsZ/TIB/P9xmZr3NbBgwHFhOjn9nzMyAp4HNzrnJQS91qeMh2n7okOMh073nMXrVb8Dfk/4RcE+my5PG7fwY/p7+tcDGwLYCJwHzgALv9wAv3YDHvP2yHhiZ6W1ox7a/iL/K24j/SuaOZLYb+A7+jrNC4NuZ3q4U7YfnvO1c532JBwXlv8fbD1uB64PSc/Y7A/wL/maMdcAa7+eGrnY8xNgPaT8eNANZRESytplIREQ6kIKBiIgoGIiIiIKBiIigYCAiIigYiIgICgYiIoKCgYiIAP8fhHsIiekG2YwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# line plot is not appropriate here (use it to measure something over time)\n",
    "ted.comments.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11a501ba8>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAD8CAYAAABgmUMCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGx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yUtb6bXAV2eh95FM+iTLNE0Mrmz4SwbHsX9r0v0M9fVR4CHg7xn8BfIWBseebwbub4/Ht7Fh8KNXfwXcDWweep1fBObadMkK9f7jDHat7wLubNMFs9A/8HLgy633e4DfbvVTGfyPcw74GHB0q7+wLc+1508deq3fau/pPuD8CXyGXs0zV1XNRP+tz6+06d75/yZn4bPTtnk6sKt9fj7N4Kqomeh9qclvjkuSunioSpLUxeCQJHUxOCRJXQwOSVIXg0OS1MXgkCR1MTgkSV0MDklSl/8PI9ITMXQHUxUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# histogram shows the frequency distribution of a single numeric variable\n",
    "ted.comments.plot(kind='hist')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11a5184e0>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAD8CAYAAABgmUMCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAExFJREFUeJzt3X+w5XV93/HnS1ZBSJVfiyW7JBfqjtFxkkI3ijFtUzBGIHFJB1odJ27INtuZ0qohM3GxmZK20xmcsSJOO1QCJIu1RkUrW6BhyEqSyR8iizqCIN2NUrgukWtBSESD6Lt/nM+Fw7Lsns/uPfecc+/zMXPmfL+f7+ec7/tzvzu8+P4432+qCkmSRvWiSRcgSZotBockqYvBIUnqYnBIkroYHJKkLgaHJKmLwSFJ6mJwSJK6GBySpC5rJl3AOJx44ok1Nzc36TI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tCm17R+mfQYDmHMLwO+sW/tK3lb8+ydJY5v2+4m4JdW6rYG5oB7DnXbAm8HPjLU/px+o7zc4xhYNbc0abvlpwN3AK+oqocB2vtJrdtK+Xt8CPgd4Edt/gTgO1X1dJsfHtczY27LH2/9Z81pwALwB+0Q3TVJjmEFb+uq+ibwAeBB4GEG2+4uVv62XtS7bQ97mxscAwe9pclKkOTHgE8D76mqJw7UdT9tM/X3SPLLwCNVdddw83661gjLZska4Azgqqo6Hfguzx662J+ZH3c7zLIJOBX4ceAYBodp9rXStvXBvNA4D3v8BsfAQW9pMuuSvJhBaHysqj7Tmr+V5OS2/GTgkda+Ev4ebwTemuQBBndTPovBHsixSRZ/vzQ8rmfG3Ja/HHh0OQteIvPAfFXd0eZvYBAkK3lbvwn4RlUtVNUPgM8AP8fK39aLerftYW9zg2NgRd/SJEmAa4H7quqDQ4t2AItXVGxmcO5jsf2d7aqMM4HHF3eFZ0VVXVpV66tqjsH2/FxVvQO4Hbigddt3zIt/iwta/5n7v9Cq+ivgoSSvak1nA/eygrc1g0NUZyY5uv1bXxzzit7WQ3q37a3Am5Mc1/bW3tzaRjfpEz3T8gLOBf4P8JfAv510PUs8tp9nsCv6FeDL7XUug+O6O4Hd7f341j8MrjL7S+BuBlerTHwchzH+XwBuatOnAV8A9gCfAo5s7Ue1+T1t+WmTrvswxvv3gV1te38WOG6lb2vg3wNfA+4BPgocuRK3NfBxBudxfsBgz2HLoWxb4Dfa+PcAF/XW4S/HJUldPFQlSepicEiSuhgckqQuBockqYvBIUnqYnBIkroYHJKkLgaHJKnL/wfyZ+IhUPrvsAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# modify the plot to be more informative\n",
    "ted[ted.comments < 1000].comments.plot(kind='hist')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(32, 19)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check how many observations we removed from the plot\n",
    "ted[ted.comments >= 1000].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11ac4a2b0>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAD8CAYAAABgmUMCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAExFJREFUeJzt3X+w5XV93/HnS1ZBSJVfiyW7JBfqjtFxkkI3ijFtUzBGIHFJB1odJ27INtuZ0qohM3GxmZK20xmcsSJOO1QCJIu1RkUrW6BhyEqSyR8iizqCIN2NUrgukWtBSESD6Lt/nM+Fw7Lsns/uPfecc+/zMXPmfL+f7+ec7/tzvzu8+P4432+qCkmSRvWiSRcgSZotBockqYvBIUnqYnBIkroYHJKkLgaHJKmLwSFJ6mJwSJK6GBySpC5rJl3AOJx44ok1Nzc36TIkaabcdddd366qtQfrtyKDY25ujl27dk26DEmaKUn+7yj9PFQlSepicEiSuhgckqQuBockqYvBIUnqYnBIkroYHJKkLgaHJKmLwSFJ6rIifzl+uOa23TyR9T5w+XkTWa8k9XCPQ5LUxeCQJHUxOCRJXQwOSVIXg0OS1MXgkCR1MTgkSV0MDklSF4NDktTF4JAkdTE4JEldDA5JUheDQ5LUxeCQJHUZW3AkuS7JI0nuGWo7PsltSXa39+Nae5J8OMmeJF9JcsbQZza3/ruTbB5XvZKk0Yxzj+MPgbfs07YN2FlVG4CdbR7gHGBDe20FroJB0ACXA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aHysqj7Tmr+V5OS2/GTgkda+Ev4ebwTemuQBBndTPovBHsixSRZ/vzQ8rmfG3Ja/HHh0OQteIvPAfFXd0eZvYBAkK3lbvwn4RlUtVNUPgM8AP8fK39aLerftYW9zg2NgRd/SJEmAa4H7quqDQ4t2AItXVGxmcO5jsf2d7aqMM4HHF3eFZ0VVXVpV66tqjsH2/FxVvQO4Hbigddt3zIt/iwta/5n7v9Cq+ivgoSSvak1nA/eygrc1g0NUZyY5uv1bXxzzit7WQ3q37a3Am5Mc1/bW3tzaRjfpEz3T8gLOBf4P8JfAv510PUs8tp9nsCv6FeDL7XUug+O6O4Hd7f341j8MrjL7S+BuBlerTHwchzH+XwBuatOnAV8A9gCfAo5s7Ue1+T1t+WmTrvswxvv3gV1te38WOG6lb2vg3wNfA+4BPgocuRK3NfBxBudxfsBgz2HLoWxb4Dfa+PcAF/XW4S/HJUldPFQlSepicEiSuhgckqQuBockqYvBIUnqYnBIkroYHJKkLgaHJKnL/wfyZ+IhUPrvsAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# can also write this using the query method\n",
    "ted.query('comments < 1000').comments.plot(kind='hist')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11a527d30>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAD8CAYAAABgmUMCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAExFJREFUeJzt3X+w5XV93/HnS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UnqYnBIkroYHJKkLgaHJKnL/wfyZ+IhUPrvsAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# can also write this using the loc accessor\n",
    "ted.loc[ted.comments < 1000, 'comments'].plot(kind='hist')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11aec0278>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAD8CAYAAABthzNFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAE/NJREFUeJzt3X+w5XV93/HnS1AQEl2QC93uLrlQd4xMpsr2VteStgaM5Ufqmg40Gqfu0G226ZBGa2biYjM1mWlncCYVZJIhEjEuVEXEH2yBanDFZDpT0WWggILdFSl7s4RdIyxRVETf/eN8Lp4u3909d/d+77k/no+ZM+f7/Xw/33Pen/vd4cX350lVIUnSgV4w7gIkSQuTASFJ6mRASJI6GRCSpE4GhCSpkwEhSepkQEiSOhkQkqROBoQkqdOx4y7gaJxyyik1OTk57jIkaVG5++67v11VE4frt6gDYnJykh07doy7DElaVJL831H6eYhJktTJgJAkdTIgJEmdDAhJUicDQpLUyYCQJHUyICRJnQwISVKnXgMiyYokNyd5KMmDSV6X5OQkdyTZ2d5Pan2T5Ooku5Lcl2Rdn7VJkg6t7zupPwB8rqouTvIi4ATgPcD2qroiyRZgC/Bu4AJgbXu9FrimvS9Ik1tuO+J1H7niojmsRJL60dseRJKXAP8EuA6gqp6pqieBDcDW1m0r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HLh93XT2N9RYGz7X6BrCyta0EvtGmPwi8daj/c/0W24vBPTPbgXOBWxncdPlt4NgDtzuDq+Re16aPbf0y7jHMcrwvAb51YN1LfVvz06ctnNy23a3AP1uq2xqYBB440u0LvBX44FD7/9dvlNey2oNgmTzOo+1Knw3cBZxWVY8BtPdTW7el9Le4Cvhd4Cdt/mXAk1X1bJsfHttz427L97f+i8mZwD7gz9phtQ8lOZElvq2r6q+APwQeBR5jsO3uZmlv62Gz3b5Hvd2XW0CM9DiPxSzJzwCfAt5ZVU8dqmtH26L7WyT5FWBvVd093NzRtUZYtlgcC6wDrqmqs4Hv8dPDDV2Wwphph0c2AGcAfxc4kcHhlQMtpW09ioON86jHv9wCYqTHeSxWSV7IIBw+WlWfbs2PJ1nZlq8E9rb2pfK3OAd4U5JHgBsZHGa6CliRZOY+n+GxPTfutvylwHfms+A5MA1MV9Vdbf5mBoGx1Lf1G4BvVdW+qvoR8GngH7G0t/Ww2W7fo97uyy0gluzjPJIEuA54sKreP7RoGzBz9cJGBucmZtrf3q6AWA/sn9l9XUyq6vKqWl1Vkwy25xer6m3AncDFrduB4575e1zc+i+q/6usqr8Gdid5RWs6j8Fj8Zf0tmZwaGl9khPav/eZcS/ZbX2A2W7fzwNvTHJS2/t6Y2sb3bhPxIzhxM+FwP8Bvgn8x3HXM4fj+kUGu4/3Afe214UMjrluB3a295Nb/zC4ouubwP0MrgwZ+ziO8m/weuDWNn0m8BVgF/BJ4LjWfnyb39WWnznuuo9wrK8GdrTt/VngpOWwrYE/AB4CHgBuAI5bitsa+DiD8yw/YrAnsOlIti/wr9v4dwGXzrYO76SWJHVaboeYJEkjMiAkSZ0MCElSJwNCktTJgJAkdTIgJEmdDAhJUicDQpLU6f8BGHUhs1TTeTsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# increase the number of bins to see more detail\n",
    "ted.loc[ted.comments < 1000, 'comments'].plot(kind='hist', bins=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11afe42b0>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAFC5JREFUeJzt3X+QXWV9x/H3d+9uspCQEGClMZu4dEhbCsUf3fFH7bSOVCJaCH/Ujo5TgjKmOIJVmdbQacehnQDSDladihMlGjtW4mBboNImKcZqp5WaIBUllWT4kayhsJBLJLkh2WW//WPPxl2yJLn3ZvfuzXm/Zu6cc5773Hu+m8nu5z7PPT8iM5EklU9HqwuQJLWGASBJJWUASFJJGQCSVFIGgCSVlAEgSSVlAEhSSRkAklRSBoAklVRnqws4mrPOOiv7+vpaXYYktZWtW7c+k5k9x+o3owOgr6+PLVu2tLoMSWorEfHE8fRzCkiSSsoAkKSSMgAkqaSOGQARsTYino6IH41rOyMiNkXE9mK5oGiPiPhMROyIiB9GxOvGvWZF0X97RKyYmh9HknS8jmcE8GXg7S9pWwXcl5lLgfuKbYBLgKXFYyVwG4wGBvAJ4A3A64FPjIWGJKk1jhkAmfkdYM9LmpcD64r1dcDl49q/kqO+B5weEQuBZcCmzNyTmVVgE0eGitQWli1bRkdHBxFBR0cHy5Yta3VJUkMa/Q7g7Mx8EqBYvqJoXwTsGtdvoGh7uXaprSxbtoyNGzdy9dVX89xzz3H11VezceNGQ0Bt6USfBxCTtOVR2o98g4iVjE4fsWTJkhNXmXQCbNq0iQ9+8IN87nOfAzi8/PznP9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7TdFxFLin5fjojbImJzRDwaEb8dEWsjYltEfHnc++2LiE9GxNaI+LeIeH1EfLt4zWVFn0pE/FVEfL/Yzx8W7W8p+t4ZEf8bEV+NUR8GXglsLvZfKer5UUQ8FBEfbcE/ncpkum6F58PHdD2A84GfAGcV22cA9wAriu33A/9UrH8ZuIPR25UuB34G/BqjH462Aq8p+iVwSbH+j8BGoAt4NfBg0b4S+LNifTawBTgHeAuwl9E74HUA/wX8ZtHv8XF1/jqwadzPcXqr/y19nNwPRwA6Gb0VuDOLaZXM3AO8Cfj74vm/A35zXP97MjOBh4CnMvOhzBwBfgz0FX0OAf9arD8E/HtmDhXrY30uBq6IiAeB+4EzgaXFc/+dmQPF+z447jXjPQr8YkR8NiLezmgYSVPGANDJKBj9xH40458/WCxHxq2PbY/dNGmoCIkJ/Yo/6GN9Arg2M19TPM7JzI0v2QfAi0xyM6bMrDI6ovg28CHgi8f4GaSmGAA6Gd0H/H5EnAkQEWcA/8noPagB3gv8xxTsdwPwwYjoKvb7SxEx5xiveR44reh/FtCRmd8A/hx43RTUKB027beElKZaZv44IlYD/x4RLwI/AD4MrI2IPwYGgfdNwa6/yOjUzgMREcV+Lj/Ga9YA/xIRTwIfAb4UEWMfzK6fghqlwzwMVJJKyikgSSopA0CSSsoAkKSSMgAkqaQMAEkqKQNAkkrKAJCkkjIAJKmk/h/OplPavCQBBQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# boxplot can also show distributions, but it's far less useful for concentrated distributions because of outliers\n",
    "ted.loc[ted.comments < 1000, 'comments'].plot(kind='box')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lessons:\n",
    "\n",
    "1. Choose your plot type based on the question you are answering and the data type(s) you are working with\n",
    "2. Use pandas one-liners to iterate through plots quickly\n",
    "3. Try modifying the plot defaults\n",
    "4. Creating plots involves decision-making"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. Plot the number of talks that took place each year\n",
    "\n",
    "Bonus exercise: calculate the average delay between filming and publishing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012       TEDxBoulder\n",
       "1307           TEDxUCL\n",
       "144     TEDGlobal 2007\n",
       "1739           TED2014\n",
       "1529    TEDGlobal 2013\n",
       "1181    TEDxWomen 2011\n",
       "2150     TEDYouth 2015\n",
       "1719           TED2014\n",
       "64             TED2007\n",
       "1178     TEDxCambridge\n",
       "Name: event, dtype: object"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# event column does not always include the year\n",
    "ted.event.sample(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    1140825600\n",
       "1    1140825600\n",
       "2    1140739200\n",
       "3    1140912000\n",
       "4    1140566400\n",
       "Name: film_date, dtype: int64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# dataset documentation for film_date says \"Unix timestamp of the filming\"\n",
    "ted.film_date.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0   1970-01-01 00:00:01.140825600\n",
       "1   1970-01-01 00:00:01.140825600\n",
       "2   1970-01-01 00:00:01.140739200\n",
       "3   1970-01-01 00:00:01.140912000\n",
       "4   1970-01-01 00:00:01.140566400\n",
       "Name: film_date, dtype: datetime64[ns]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# results don't look right\n",
    "pd.to_datetime(ted.film_date).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[pandas documentation for `to_datetime`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_datetime.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0   2006-02-25\n",
       "1   2006-02-25\n",
       "2   2006-02-24\n",
       "3   2006-02-26\n",
       "4   2006-02-22\n",
       "Name: film_date, dtype: datetime64[ns]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# now the results look right\n",
    "pd.to_datetime(ted.film_date, unit='s').head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "ted['film_datetime'] = pd.to_datetime(ted.film_date, unit='s')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>event</th>\n",
       "      <th>film_datetime</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>831</th>\n",
       "      <td>TEDWomen 2010</td>\n",
       "      <td>2010-12-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2464</th>\n",
       "      <td>TED2017</td>\n",
       "      <td>2017-04-24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2392</th>\n",
       "      <td>TEDxBeaconStreet</td>\n",
       "      <td>2016-11-19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1307</th>\n",
       "      <td>TEDxUCL</td>\n",
       "      <td>2012-06-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2234</th>\n",
       "      <td>TED2016</td>\n",
       "      <td>2016-02-17</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 event film_datetime\n",
       "831      TEDWomen 2010    2010-12-08\n",
       "2464           TED2017    2017-04-24\n",
       "2392  TEDxBeaconStreet    2016-11-19\n",
       "1307           TEDxUCL    2012-06-03\n",
       "2234           TED2016    2016-02-17"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# verify that event name matches film_datetime for a random sample\n",
    "ted[['event', 'film_datetime']].sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "comments                       int64\n",
       "description                   object\n",
       "duration                       int64\n",
       "event                         object\n",
       "film_date                      int64\n",
       "languages                      int64\n",
       "main_speaker                  object\n",
       "name                          object\n",
       "num_speaker                    int64\n",
       "published_date                 int64\n",
       "ratings                       object\n",
       "related_talks                 object\n",
       "speaker_occupation            object\n",
       "tags                          object\n",
       "title                         object\n",
       "url                           object\n",
       "views                          int64\n",
       "comments_per_view            float64\n",
       "views_per_comment            float64\n",
       "film_datetime         datetime64[ns]\n",
       "dtype: object"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# new column uses the datetime data type (this was an automatic conversion)\n",
    "ted.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    2006\n",
       "1    2006\n",
       "2    2006\n",
       "3    2006\n",
       "4    2006\n",
       "Name: film_datetime, dtype: int64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# datetime columns have convenient attributes under the dt namespace\n",
    "ted.film_datetime.dt.year.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    ted2006\n",
       "1    ted2006\n",
       "2    ted2006\n",
       "3    ted2006\n",
       "4    ted2006\n",
       "Name: event, dtype: object"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# similar to string methods under the str namespace\n",
    "ted.event.str.lower().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2013    270\n",
       "2011    270\n",
       "2010    267\n",
       "2012    267\n",
       "2016    246\n",
       "2015    239\n",
       "2014    237\n",
       "2009    232\n",
       "2007    114\n",
       "2017     98\n",
       "2008     84\n",
       "2005     66\n",
       "2006     50\n",
       "2003     33\n",
       "2004     33\n",
       "2002     27\n",
       "1998      6\n",
       "2001      5\n",
       "1983      1\n",
       "1991      1\n",
       "1994      1\n",
       "1990      1\n",
       "1984      1\n",
       "1972      1\n",
       "Name: film_datetime, dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# count the number of talks each year using value_counts()\n",
    "ted.film_datetime.dt.year.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11a477278>"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3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KQ4Bb2ISIr7/4ba06k222YTAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# points are plotted and connected in the order you give them to pandas\n",
    "ted.film_datetime.dt.year.value_counts().plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x11b48dc18>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xl0nNWZ5/HvU1JplyXZlmTjHWO8sIMCBNIsBhOzdJz0TNIkmYRJMk36DMlJOumeQ7aZTmfoyczpLJ3TnUygIQ0zWQ6ZbCSQBJsdAgRD402ysWRsLGyr5EWbtZWkO3/UW3bZ1lKqVfW+v885darq1n2rnnpV9ejWfe+9rznnEBER/wrlOwAREckuJXoREZ9TohcR8TklehERn1OiFxHxOSV6ERGfU6IXEfE5JXoREZ9TohcR8bnifAcAMHfuXLd06dJ8hyEiUlBeffXVw865+qnqzYhEv3TpUjZv3pzvMERECoqZ7UumnrpuRER8ToleRMTnlOhFRHxOiV5ExOeU6EVEfE6JXkTE55ToRUR8bkaMoxcRyZfB6Cgv7jlCa0cfV5w9m/PPqiEUsqS27R2M8vzuw4yMOf70orOyHGnqlOhFJHAOdQ/y5M4IT+7s4PnWwwxGx048Vl9dyvUr61m7qpF3rZhLVempaXLv4ePethFefvMI0dHYebebltYxv6Y8p+8jWUr0IhII+4/289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SvQiIj6nRC8i4nNK9CIiPqdELyLic0r0IiI+p0QvIuJzSvQiIj73/wH88ECJ9TBU9QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# need to sort the index before plotting\n",
    "ted.film_datetime.dt.year.value_counts().sort_index().plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2017-08-27 00:00:00')"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# we only have partial data for 2017\n",
    "ted.film_datetime.max()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lessons:\n",
    "\n",
    "1. Read the documentation\n",
    "2. Use the datetime data type for dates and times\n",
    "3. Check your work as you go\n",
    "4. Consider excluding data if it might not be relevant"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 5. What were the \"best\" events in TED history to attend?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "TED2014    84\n",
       "TED2009    83\n",
       "TED2013    77\n",
       "TED2016    77\n",
       "TED2015    75\n",
       "Name: event, dtype: int64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# count the number of talks (great if you value variety, but they may not be great talks)\n",
    "ted.event.value_counts().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "event\n",
       "AORN Congress                  149818.0\n",
       "Arbejdsglaede Live             971594.0\n",
       "BBC TV                         521974.0\n",
       "Bowery Poetry Club             676741.0\n",
       "Business Innovation Factory    304086.0\n",
       "Name: views, dtype: float64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# use views as a proxy for \"quality of talk\"\n",
    "ted.groupby('event').views.mean().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "event\n",
       "TEDxNorrkoping        6569493.0\n",
       "TEDxCreativeCoast     8444981.0\n",
       "TEDxBloomington       9484259.5\n",
       "TEDxHouston          16140250.5\n",
       "TEDxPuget Sound      34309432.0\n",
       "Name: views, dtype: float64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# find the largest values, but we don't know how many talks are being averaged\n",
    "ted.groupby('event').views.mean().sort_values().tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>event</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>TEDxNorrkoping</th>\n",
       "      <td>1</td>\n",
       "      <td>6569493.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TEDxCreativeCoast</th>\n",
       "      <td>1</td>\n",
       "      <td>8444981.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TEDxBloomington</th>\n",
       "      <td>2</td>\n",
       "      <td>9484259.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TEDxHouston</th>\n",
       "      <td>2</td>\n",
       "      <td>16140250.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TEDxPuget Sound</th>\n",
       "      <td>1</td>\n",
       "      <td>34309432.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   count        mean\n",
       "event                               \n",
       "TEDxNorrkoping         1   6569493.0\n",
       "TEDxCreativeCoast      1   8444981.0\n",
       "TEDxBloomington        2   9484259.5\n",
       "TEDxHouston            2  16140250.5\n",
       "TEDxPuget Sound        1  34309432.0"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# show the number of talks along with the mean (events with the highest means had only 1 or 2 talks)\n",
    "ted.groupby('event').views.agg(['count', 'mean']).sort_values('mean').tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>mean</th>\n",
       "      <th>sum</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>event</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>TED2006</th>\n",
       "      <td>45</td>\n",
       "      <td>3.274345e+06</td>\n",
       "      <td>147345533</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TED2015</th>\n",
       "      <td>75</td>\n",
       "      <td>2.011017e+06</td>\n",
       "      <td>150826305</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TEDGlobal 2013</th>\n",
       "      <td>66</td>\n",
       "      <td>2.584163e+06</td>\n",
       "      <td>170554736</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TED2014</th>\n",
       "      <td>84</td>\n",
       "      <td>2.072874e+06</td>\n",
       "      <td>174121423</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TED2013</th>\n",
       "      <td>77</td>\n",
       "      <td>2.302700e+06</td>\n",
       "      <td>177307937</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                count          mean        sum\n",
       "event                                         \n",
       "TED2006            45  3.274345e+06  147345533\n",
       "TED2015            75  2.011017e+06  150826305\n",
       "TEDGlobal 2013     66  2.584163e+06  170554736\n",
       "TED2014            84  2.072874e+06  174121423\n",
       "TED2013            77  2.302700e+06  177307937"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calculate the total views per event\n",
    "ted.groupby('event').views.agg(['count', 'mean', 'sum']).sort_values('sum').tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lessons:\n",
    "\n",
    "1. Think creatively for how you can use the data you have to answer your question\n",
    "2. Watch out for small sample sizes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6. Unpack the ratings data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    [{'id': 7, 'name': 'Funny', 'count': 19645}, {...\n",
       "1    [{'id': 7, 'name': 'Funny', 'count': 544}, {'i...\n",
       "2    [{'id': 7, 'name': 'Funny', 'count': 964}, {'i...\n",
       "3    [{'id': 3, 'name': 'Courageous', 'count': 760}...\n",
       "4    [{'id': 9, 'name': 'Ingenious', 'count': 3202}...\n",
       "Name: ratings, dtype: object"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# previously, users could tag talks on the TED website (funny, inspiring, confusing, etc.)\n",
    "ted.ratings.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"[{'id': 7, 'name': 'Funny', 'count': 19645}, {'id': 1, 'name': 'Beautiful', 'count': 4573}, {'id': 9, 'name': 'Ingenious', 'count': 6073}, {'id': 3, 'name': 'Courageous', 'count': 3253}, {'id': 11, 'name': 'Longwinded', 'count': 387}, {'id': 2, 'name': 'Confusing', 'count': 242}, {'id': 8, 'name': 'Informative', 'count': 7346}, {'id': 22, 'name': 'Fascinating', 'count': 10581}, {'id': 21, 'name': 'Unconvincing', 'count': 300}, {'id': 24, 'name': 'Persuasive', 'count': 10704}, {'id': 23, 'name': 'Jaw-dropping', 'count': 4439}, {'id': 25, 'name': 'OK', 'count': 1174}, {'id': 26, 'name': 'Obnoxious', 'count': 209}, {'id': 10, 'name': 'Inspiring', 'count': 24924}]\""
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# two ways to examine the ratings data for the first talk\n",
    "ted.loc[0, 'ratings']\n",
    "ted.ratings[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# this is a string not a list\n",
    "type(ted.ratings[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "# convert this into something useful using Python's ast module (Abstract Syntax Tree)\n",
    "import ast"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# literal_eval() allows you to evaluate a string containing a Python literal or container\n",
    "ast.literal_eval('[1, 2, 3]')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# if you have a string representation of something, you can retrieve what it actually represents\n",
    "type(ast.literal_eval('[1, 2, 3]'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 7, 'name': 'Funny', 'count': 19645},\n",
       " {'id': 1, 'name': 'Beautiful', 'count': 4573},\n",
       " {'id': 9, 'name': 'Ingenious', 'count': 6073},\n",
       " {'id': 3, 'name': 'Courageous', 'count': 3253},\n",
       " {'id': 11, 'name': 'Longwinded', 'count': 387},\n",
       " {'id': 2, 'name': 'Confusing', 'count': 242},\n",
       " {'id': 8, 'name': 'Informative', 'count': 7346},\n",
       " {'id': 22, 'name': 'Fascinating', 'count': 10581},\n",
       " {'id': 21, 'name': 'Unconvincing', 'count': 300},\n",
       " {'id': 24, 'name': 'Persuasive', 'count': 10704},\n",
       " {'id': 23, 'name': 'Jaw-dropping', 'count': 4439},\n",
       " {'id': 25, 'name': 'OK', 'count': 1174},\n",
       " {'id': 26, 'name': 'Obnoxious', 'count': 209},\n",
       " {'id': 10, 'name': 'Inspiring', 'count': 24924}]"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# unpack the ratings data for the first talk\n",
    "ast.literal_eval(ted.ratings[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# now we have a list (of dictionaries)\n",
    "type(ast.literal_eval(ted.ratings[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "# define a function to convert an element in the ratings Series from string to list\n",
    "def str_to_list(ratings_str):\n",
    "    return ast.literal_eval(ratings_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 7, 'name': 'Funny', 'count': 19645},\n",
       " {'id': 1, 'name': 'Beautiful', 'count': 4573},\n",
       " {'id': 9, 'name': 'Ingenious', 'count': 6073},\n",
       " {'id': 3, 'name': 'Courageous', 'count': 3253},\n",
       " {'id': 11, 'name': 'Longwinded', 'count': 387},\n",
       " {'id': 2, 'name': 'Confusing', 'count': 242},\n",
       " {'id': 8, 'name': 'Informative', 'count': 7346},\n",
       " {'id': 22, 'name': 'Fascinating', 'count': 10581},\n",
       " {'id': 21, 'name': 'Unconvincing', 'count': 300},\n",
       " {'id': 24, 'name': 'Persuasive', 'count': 10704},\n",
       " {'id': 23, 'name': 'Jaw-dropping', 'count': 4439},\n",
       " {'id': 25, 'name': 'OK', 'count': 1174},\n",
       " {'id': 26, 'name': 'Obnoxious', 'count': 209},\n",
       " {'id': 10, 'name': 'Inspiring', 'count': 24924}]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# test the function\n",
    "str_to_list(ted.ratings[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    [{'id': 7, 'name': 'Funny', 'count': 19645}, {...\n",
       "1    [{'id': 7, 'name': 'Funny', 'count': 544}, {'i...\n",
       "2    [{'id': 7, 'name': 'Funny', 'count': 964}, {'i...\n",
       "3    [{'id': 3, 'name': 'Courageous', 'count': 760}...\n",
       "4    [{'id': 9, 'name': 'Ingenious', 'count': 3202}...\n",
       "Name: ratings, dtype: object"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Series apply method applies a function to every element in a Series and returns a Series\n",
    "ted.ratings.apply(str_to_list).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    [{'id': 7, 'name': 'Funny', 'count': 19645}, {...\n",
       "1    [{'id': 7, 'name': 'Funny', 'count': 544}, {'i...\n",
       "2    [{'id': 7, 'name': 'Funny', 'count': 964}, {'i...\n",
       "3    [{'id': 3, 'name': 'Courageous', 'count': 760}...\n",
       "4    [{'id': 9, 'name': 'Ingenious', 'count': 3202}...\n",
       "Name: ratings, dtype: object"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# lambda is a shorter alternative\n",
    "ted.ratings.apply(lambda x: ast.literal_eval(x)).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    [{'id': 7, 'name': 'Funny', 'count': 19645}, {...\n",
       "1    [{'id': 7, 'name': 'Funny', 'count': 544}, {'i...\n",
       "2    [{'id': 7, 'name': 'Funny', 'count': 964}, {'i...\n",
       "3    [{'id': 3, 'name': 'Courageous', 'count': 760}...\n",
       "4    [{'id': 9, 'name': 'Ingenious', 'count': 3202}...\n",
       "Name: ratings, dtype: object"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# an even shorter alternative is to apply the function directly (without lambda)\n",
    "ted.ratings.apply(ast.literal_eval).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "ted['ratings_list'] = ted.ratings.apply(lambda x: ast.literal_eval(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 7, 'name': 'Funny', 'count': 19645},\n",
       " {'id': 1, 'name': 'Beautiful', 'count': 4573},\n",
       " {'id': 9, 'name': 'Ingenious', 'count': 6073},\n",
       " {'id': 3, 'name': 'Courageous', 'count': 3253},\n",
       " {'id': 11, 'name': 'Longwinded', 'count': 387},\n",
       " {'id': 2, 'name': 'Confusing', 'count': 242},\n",
       " {'id': 8, 'name': 'Informative', 'count': 7346},\n",
       " {'id': 22, 'name': 'Fascinating', 'count': 10581},\n",
       " {'id': 21, 'name': 'Unconvincing', 'count': 300},\n",
       " {'id': 24, 'name': 'Persuasive', 'count': 10704},\n",
       " {'id': 23, 'name': 'Jaw-dropping', 'count': 4439},\n",
       " {'id': 25, 'name': 'OK', 'count': 1174},\n",
       " {'id': 26, 'name': 'Obnoxious', 'count': 209},\n",
       " {'id': 10, 'name': 'Inspiring', 'count': 24924}]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check that the new Series looks as expected\n",
    "ted.ratings_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# each element in the Series is a list\n",
    "type(ted.ratings_list[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('O')"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# data type of the new Series is object\n",
    "ted.ratings_list.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "comments                       int64\n",
       "description                   object\n",
       "duration                       int64\n",
       "event                         object\n",
       "film_date                      int64\n",
       "languages                      int64\n",
       "main_speaker                  object\n",
       "name                          object\n",
       "num_speaker                    int64\n",
       "published_date                 int64\n",
       "ratings                       object\n",
       "related_talks                 object\n",
       "speaker_occupation            object\n",
       "tags                          object\n",
       "title                         object\n",
       "url                           object\n",
       "views                          int64\n",
       "comments_per_view            float64\n",
       "views_per_comment            float64\n",
       "film_datetime         datetime64[ns]\n",
       "ratings_list                  object\n",
       "dtype: object"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# object is not just for strings\n",
    "ted.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lessons:\n",
    "\n",
    "1. Pay attention to data types in pandas\n",
    "2. Use apply any time it is necessary"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 7. Count the total number of ratings received by each talk\n",
    "\n",
    "Bonus exercises:\n",
    "\n",
    "- for each talk, calculate the percentage of ratings that were negative\n",
    "- for each talk, calculate the average number of ratings it received per day since it was published"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 7, 'name': 'Funny', 'count': 19645},\n",
       " {'id': 1, 'name': 'Beautiful', 'count': 4573},\n",
       " {'id': 9, 'name': 'Ingenious', 'count': 6073},\n",
       " {'id': 3, 'name': 'Courageous', 'count': 3253},\n",
       " {'id': 11, 'name': 'Longwinded', 'count': 387},\n",
       " {'id': 2, 'name': 'Confusing', 'count': 242},\n",
       " {'id': 8, 'name': 'Informative', 'count': 7346},\n",
       " {'id': 22, 'name': 'Fascinating', 'count': 10581},\n",
       " {'id': 21, 'name': 'Unconvincing', 'count': 300},\n",
       " {'id': 24, 'name': 'Persuasive', 'count': 10704},\n",
       " {'id': 23, 'name': 'Jaw-dropping', 'count': 4439},\n",
       " {'id': 25, 'name': 'OK', 'count': 1174},\n",
       " {'id': 26, 'name': 'Obnoxious', 'count': 209},\n",
       " {'id': 10, 'name': 'Inspiring', 'count': 24924}]"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# expected result (for each talk) is sum of count\n",
    "ted.ratings_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "# start by building a simple function\n",
    "def get_num_ratings(list_of_dicts):\n",
    "    return list_of_dicts[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 7, 'name': 'Funny', 'count': 19645}"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# pass it a list, and it returns the first element in the list, which is a dictionary\n",
    "get_num_ratings(ted.ratings_list[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "# modify the function to return the vote count\n",
    "def get_num_ratings(list_of_dicts):\n",
    "    return list_of_dicts[0]['count']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19645"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# pass it a list, and it returns a value from the first dictionary in the list\n",
    "get_num_ratings(ted.ratings_list[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "# modify the function to get the sum of count\n",
    "def get_num_ratings(list_of_dicts):\n",
    "    num = 0\n",
    "    for d in list_of_dicts:\n",
    "        num = num + d['count']\n",
    "    return num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "93850"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# looks about right\n",
    "get_num_ratings(ted.ratings_list[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 7, 'name': 'Funny', 'count': 544},\n",
       " {'id': 3, 'name': 'Courageous', 'count': 139},\n",
       " {'id': 2, 'name': 'Confusing', 'count': 62},\n",
       " {'id': 1, 'name': 'Beautiful', 'count': 58},\n",
       " {'id': 21, 'name': 'Unconvincing', 'count': 258},\n",
       " {'id': 11, 'name': 'Longwinded', 'count': 113},\n",
       " {'id': 8, 'name': 'Informative', 'count': 443},\n",
       " {'id': 10, 'name': 'Inspiring', 'count': 413},\n",
       " {'id': 22, 'name': 'Fascinating', 'count': 132},\n",
       " {'id': 9, 'name': 'Ingenious', 'count': 56},\n",
       " {'id': 24, 'name': 'Persuasive', 'count': 268},\n",
       " {'id': 23, 'name': 'Jaw-dropping', 'count': 116},\n",
       " {'id': 26, 'name': 'Obnoxious', 'count': 131},\n",
       " {'id': 25, 'name': 'OK', 'count': 203}]"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check with another record\n",
    "ted.ratings_list[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2936"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# looks about right\n",
    "get_num_ratings(ted.ratings_list[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    93850\n",
       "1     2936\n",
       "2     2824\n",
       "3     3728\n",
       "4    25620\n",
       "Name: ratings_list, dtype: int64"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# apply it to every element in the Series\n",
    "ted.ratings_list.apply(get_num_ratings).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "93850"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# another alternative is to use a generator expression\n",
    "sum((d['count'] for d in ted.ratings_list[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    93850\n",
       "1     2936\n",
       "2     2824\n",
       "3     3728\n",
       "4    25620\n",
       "Name: ratings_list, dtype: int64"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# use lambda to apply this method\n",
    "ted.ratings_list.apply(lambda x: sum((d['count'] for d in x))).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "93850"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# another alternative is to use pd.DataFrame()\n",
    "pd.DataFrame(ted.ratings_list[0])['count'].sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    93850\n",
       "1     2936\n",
       "2     2824\n",
       "3     3728\n",
       "4    25620\n",
       "Name: ratings_list, dtype: int64"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# use lambda to apply this method\n",
    "ted.ratings_list.apply(lambda x: pd.DataFrame(x)['count'].sum()).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [],
   "source": [
    "ted['num_ratings'] = ted.ratings_list.apply(get_num_ratings)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count     2550.000000\n",
       "mean      2436.408235\n",
       "std       4226.795631\n",
       "min         68.000000\n",
       "25%        870.750000\n",
       "50%       1452.500000\n",
       "75%       2506.750000\n",
       "max      93850.000000\n",
       "Name: num_ratings, dtype: float64"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# do one more check\n",
    "ted.num_ratings.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lessons:\n",
    "\n",
    "1. Write your code in small chunks, and check your work as you go\n",
    "2. Lambda is best for simple functions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 8. Which occupations deliver the funniest TED talks on average?\n",
    "\n",
    "Bonus exercises:\n",
    "\n",
    "- for each talk, calculate the most frequent rating\n",
    "- for each talk, clean the occupation data so that there's only one occupation per talk"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 1: Count the number of funny ratings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    [{'id': 7, 'name': 'Funny', 'count': 19645}, {...\n",
       "1    [{'id': 7, 'name': 'Funny', 'count': 544}, {'i...\n",
       "2    [{'id': 7, 'name': 'Funny', 'count': 964}, {'i...\n",
       "3    [{'id': 3, 'name': 'Courageous', 'count': 760}...\n",
       "4    [{'id': 9, 'name': 'Ingenious', 'count': 3202}...\n",
       "Name: ratings_list, dtype: object"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# \"Funny\" is not always the first dictionary in the list\n",
    "ted.ratings_list.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True    2550\n",
       "Name: ratings, dtype: int64"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check ratings (not ratings_list) to see if \"Funny\" is always a rating type\n",
    "ted.ratings.str.contains('Funny').value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "# write a custom function\n",
    "def get_funny_ratings(list_of_dicts):\n",
    "    for d in list_of_dicts:\n",
    "        if d['name'] == 'Funny':\n",
    "            return d['count']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': 3, 'name': 'Courageous', 'count': 760},\n",
       " {'id': 1, 'name': 'Beautiful', 'count': 291},\n",
       " {'id': 2, 'name': 'Confusing', 'count': 32},\n",
       " {'id': 7, 'name': 'Funny', 'count': 59},\n",
       " {'id': 9, 'name': 'Ingenious', 'count': 105},\n",
       " {'id': 21, 'name': 'Unconvincing', 'count': 36},\n",
       " {'id': 11, 'name': 'Longwinded', 'count': 53},\n",
       " {'id': 8, 'name': 'Informative', 'count': 380},\n",
       " {'id': 10, 'name': 'Inspiring', 'count': 1070},\n",
       " {'id': 22, 'name': 'Fascinating', 'count': 132},\n",
       " {'id': 24, 'name': 'Persuasive', 'count': 460},\n",
       " {'id': 23, 'name': 'Jaw-dropping', 'count': 230},\n",
       " {'id': 26, 'name': 'Obnoxious', 'count': 35},\n",
       " {'id': 25, 'name': 'OK', 'count': 85}]"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# examine a record in which \"Funny\" is not the first dictionary\n",
    "ted.ratings_list[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "59"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check that the function works\n",
    "get_funny_ratings(ted.ratings_list[3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    19645\n",
       "1      544\n",
       "2      964\n",
       "3       59\n",
       "4     1390\n",
       "Name: funny_ratings, dtype: int64"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# apply it to every element in the Series\n",
    "ted['funny_ratings'] = ted.ratings_list.apply(get_funny_ratings)\n",
    "ted.funny_ratings.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# check for missing values\n",
    "ted.funny_ratings.isna().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 2: Calculate the percentage of ratings that are funny"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [],
   "source": [
    "ted['funny_rate'] = ted.funny_ratings / ted.num_ratings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1849                       Science humorist\n",
       "337                                Comedian\n",
       "124     Performance poet, multimedia artist\n",
       "315                                  Expert\n",
       "1168             Social energy entrepreneur\n",
       "1468                          Ornithologist\n",
       "595                  Comedian, voice artist\n",
       "1534                         Cartoon editor\n",
       "97                                 Satirist\n",
       "2297                          Actor, writer\n",
       "568                                Comedian\n",
       "675                          Data scientist\n",
       "21                     Humorist, web artist\n",
       "194                                Jugglers\n",
       "2273                    Comedian and writer\n",
       "2114                    Comedian and writer\n",
       "173                                Investor\n",
       "747                                Comedian\n",
       "1398                               Comedian\n",
       "685             Actor, comedian, playwright\n",
       "Name: speaker_occupation, dtype: object"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# \"gut check\" that this calculation makes sense by examining the occupations of the funniest talks\n",
    "ted.sort_values('funny_rate').speaker_occupation.tail(20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2549               Game designer\n",
       "1612                   Biologist\n",
       "612                     Sculptor\n",
       "998               Penguin expert\n",
       "593                     Engineer\n",
       "284               Space activist\n",
       "1041         Biomedical engineer\n",
       "1618      Spinal cord researcher\n",
       "2132    Computational geneticist\n",
       "442                     Sculptor\n",
       "426              Author, thinker\n",
       "458                     Educator\n",
       "2437      Environmental engineer\n",
       "1491             Photojournalist\n",
       "1893     Forensic anthropologist\n",
       "783             Marine biologist\n",
       "195                    Kenyan MP\n",
       "772             HIV/AIDS fighter\n",
       "788            Building activist\n",
       "936                Neuroengineer\n",
       "Name: speaker_occupation, dtype: object"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# examine the occupations of the least funny talks\n",
    "ted.sort_values('funny_rate').speaker_occupation.head(20)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 3: Analyze the funny rate by occupation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "speaker_occupation\n",
       "Comedian                       0.512457\n",
       "Actor, writer                  0.515152\n",
       "Actor, comedian, playwright    0.558107\n",
       "Jugglers                       0.566828\n",
       "Comedian and writer            0.602085\n",
       "Name: funny_rate, dtype: float64"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# calculate the mean funny rate for each occupation\n",
    "ted.groupby('speaker_occupation').funny_rate.mean().sort_values().tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "count       2544\n",
       "unique      1458\n",
       "top       Writer\n",
       "freq          45\n",
       "Name: speaker_occupation, dtype: object"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# however, most of the occupations have a sample size of 1\n",
    "ted.speaker_occupation.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 4: Focus on occupations that are well-represented in the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Writer                                      45\n",
       "Artist                                      34\n",
       "Designer                                    34\n",
       "Journalist                                  33\n",
       "Entrepreneur                                31\n",
       "Architect                                   30\n",
       "Inventor                                    27\n",
       "Psychologist                                26\n",
       "Photographer                                25\n",
       "Filmmaker                                   21\n",
       "Author                                      20\n",
       "Economist                                   20\n",
       "Neuroscientist                              20\n",
       "Educator                                    20\n",
       "Roboticist                                  16\n",
       "Philosopher                                 16\n",
       "Biologist                                   15\n",
       "Physicist                                   14\n",
       "Musician                                    11\n",
       "Marine biologist                            11\n",
       "Technologist                                10\n",
       "Activist                                    10\n",
       "Global health expert; data visionary        10\n",
       "Historian                                    9\n",
       "Singer/songwriter                            9\n",
       "Oceanographer                                9\n",
       "Behavioral economist                         9\n",
       "Poet                                         9\n",
       "Astronomer                                   9\n",
       "Graphic designer                             9\n",
       "                                            ..\n",
       "Anatomical artist                            1\n",
       "Literary scholar                             1\n",
       "Social entrepreneur, lawyer                  1\n",
       "Physician, bioengineer and entrepreneur      1\n",
       "medical inventor                             1\n",
       "Mental health advocate                       1\n",
       "Public sector researcher                     1\n",
       "Speleologist                                 1\n",
       "Disaster relief expert                       1\n",
       "Artist and curator                           1\n",
       "Finance journalist                           1\n",
       "Wildlife conservationist                     1\n",
       "Sex worker and activist                      1\n",
       "Connector                                    1\n",
       "Sociologist, human rights activist           1\n",
       "Author, producer                             1\n",
       "Painter                                      1\n",
       "Policy expert                                1\n",
       "Environmental economist                      1\n",
       "Sound artist, composer                       1\n",
       "Senator                                      1\n",
       "High school principal                        1\n",
       "Poet of code                                 1\n",
       "Healthcare revolutionary                     1\n",
       "Circular economy advocate                    1\n",
       "Caregiver                                    1\n",
       "Transportation geek                          1\n",
       "Music icon                                   1\n",
       "Surprisologist                               1\n",
       "Psychiatrist and writer                      1\n",
       "Name: speaker_occupation, Length: 1458, dtype: int64"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# count how many times each occupation appears\n",
    "ted.speaker_occupation.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# value_counts() outputs a pandas Series, thus we can use pandas to manipulate the output\n",
    "occupation_counts = ted.speaker_occupation.value_counts()\n",
    "type(occupation_counts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Writer                                        45\n",
       "Artist                                        34\n",
       "Designer                                      34\n",
       "Journalist                                    33\n",
       "Entrepreneur                                  31\n",
       "Architect                                     30\n",
       "Inventor                                      27\n",
       "Psychologist                                  26\n",
       "Photographer                                  25\n",
       "Filmmaker                                     21\n",
       "Author                                        20\n",
       "Economist                                     20\n",
       "Neuroscientist                                20\n",
       "Educator                                      20\n",
       "Roboticist                                    16\n",
       "Philosopher                                   16\n",
       "Biologist                                     15\n",
       "Physicist                                     14\n",
       "Musician                                      11\n",
       "Marine biologist                              11\n",
       "Technologist                                  10\n",
       "Activist                                      10\n",
       "Global health expert; data visionary          10\n",
       "Historian                                      9\n",
       "Singer/songwriter                              9\n",
       "Oceanographer                                  9\n",
       "Behavioral economist                           9\n",
       "Poet                                           9\n",
       "Astronomer                                     9\n",
       "Graphic designer                               9\n",
       "                                              ..\n",
       "Legal activist                                 6\n",
       "Photojournalist                                6\n",
       "Evolutionary biologist                         6\n",
       "Singer-songwriter                              6\n",
       "Performance poet, multimedia artist            6\n",
       "Climate advocate                               6\n",
       "Techno-illusionist                             6\n",
       "Social entrepreneur                            6\n",
       "Comedian                                       6\n",
       "Reporter                                       6\n",
       "Writer, activist                               6\n",
       "Investor and advocate for moral leadership     5\n",
       "Surgeon                                        5\n",
       "Paleontologist                                 5\n",
       "Physician                                      5\n",
       "Tech visionary                                 5\n",
       "Chef                                           5\n",
       "Science writer                                 5\n",
       "Game designer                                  5\n",
       "Cartoonist                                     5\n",
       "Producer                                       5\n",
       "Violinist                                      5\n",
       "Researcher                                     5\n",
       "Social Media Theorist                          5\n",
       "Environmentalist, futurist                     5\n",
       "Data scientist                                 5\n",
       "Musician, activist                             5\n",
       "Sculptor                                       5\n",
       "Chemist                                        5\n",
       "Sound consultant                               5\n",
       "Name: speaker_occupation, Length: 68, dtype: int64"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# show occupations which appear at least 5 times\n",
    "occupation_counts[occupation_counts >= 5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Writer', 'Artist', 'Designer', 'Journalist', 'Entrepreneur',\n",
       "       'Architect', 'Inventor', 'Psychologist', 'Photographer', 'Filmmaker',\n",
       "       'Author', 'Economist', 'Neuroscientist', 'Educator', 'Roboticist',\n",
       "       'Philosopher', 'Biologist', 'Physicist', 'Musician', 'Marine biologist',\n",
       "       'Technologist', 'Activist', 'Global health expert; data visionary',\n",
       "       'Historian', 'Singer/songwriter', 'Oceanographer',\n",
       "       'Behavioral economist', 'Poet', 'Astronomer', 'Graphic designer',\n",
       "       'Philanthropist', 'Novelist', 'Social psychologist', 'Engineer',\n",
       "       'Computer scientist', 'Futurist', 'Astrophysicist', 'Mathematician',\n",
       "       'Legal activist', 'Photojournalist', 'Evolutionary biologist',\n",
       "       'Singer-songwriter', 'Performance poet, multimedia artist',\n",
       "       'Climate advocate', 'Techno-illusionist', 'Social entrepreneur',\n",
       "       'Comedian', 'Reporter', 'Writer, activist',\n",
       "       'Investor and advocate for moral leadership', 'Surgeon',\n",
       "       'Paleontologist', 'Physician', 'Tech visionary', 'Chef',\n",
       "       'Science writer', 'Game designer', 'Cartoonist', 'Producer',\n",
       "       'Violinist', 'Researcher', 'Social Media Theorist',\n",
       "       'Environmentalist, futurist', 'Data scientist', 'Musician, activist',\n",
       "       'Sculptor', 'Chemist', 'Sound consultant'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# save the index of this Series\n",
    "top_occupations = occupation_counts[occupation_counts >= 5].index\n",
    "top_occupations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 5: Re-analyze the funny rate by occupation (for top occupations only)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(786, 24)"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# filter DataFrame to include only those occupations\n",
    "ted_top_occupations = ted[ted.speaker_occupation.isin(top_occupations)]\n",
    "ted_top_occupations.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "speaker_occupation\n",
       "Surgeon                                       0.002465\n",
       "Physician                                     0.004515\n",
       "Photojournalist                               0.004908\n",
       "Investor and advocate for moral leadership    0.005198\n",
       "Photographer                                  0.007152\n",
       "Environmentalist, futurist                    0.007317\n",
       "Violinist                                     0.009534\n",
       "Singer-songwriter                             0.010597\n",
       "Chemist                                       0.010970\n",
       "Philanthropist                                0.012522\n",
       "Activist                                      0.012539\n",
       "Astrophysicist                                0.013147\n",
       "Oceanographer                                 0.014596\n",
       "Paleontologist                                0.015780\n",
       "Social psychologist                           0.015887\n",
       "Tech visionary                                0.016654\n",
       "Sculptor                                      0.016960\n",
       "Social Media Theorist                         0.017450\n",
       "Social entrepreneur                           0.017921\n",
       "Inventor                                      0.021801\n",
       "Sound consultant                              0.022011\n",
       "Legal activist                                0.022303\n",
       "Historian                                     0.023215\n",
       "Musician, activist                            0.023395\n",
       "Economist                                     0.025488\n",
       "Writer, activist                              0.026665\n",
       "Journalist                                    0.027997\n",
       "Computer scientist                            0.029070\n",
       "Architect                                     0.030579\n",
       "Engineer                                      0.031711\n",
       "                                                ...   \n",
       "Roboticist                                    0.042777\n",
       "Astronomer                                    0.044581\n",
       "Psychologist                                  0.044984\n",
       "Musician                                      0.045336\n",
       "Physicist                                     0.046302\n",
       "Filmmaker                                     0.048603\n",
       "Futurist                                      0.050460\n",
       "Behavioral economist                          0.050460\n",
       "Technologist                                  0.050965\n",
       "Chef                                          0.054207\n",
       "Science writer                                0.055993\n",
       "Designer                                      0.059287\n",
       "Writer                                        0.060745\n",
       "Game designer                                 0.062317\n",
       "Reporter                                      0.066250\n",
       "Evolutionary biologist                        0.069157\n",
       "Novelist                                      0.070876\n",
       "Entrepreneur                                  0.073295\n",
       "Author                                        0.075508\n",
       "Artist                                        0.078939\n",
       "Global health expert; data visionary          0.090306\n",
       "Poet                                          0.107398\n",
       "Graphic designer                              0.135718\n",
       "Techno-illusionist                            0.152171\n",
       "Cartoonist                                    0.162120\n",
       "Data scientist                                0.184076\n",
       "Producer                                      0.202531\n",
       "Singer/songwriter                             0.252205\n",
       "Performance poet, multimedia artist           0.306468\n",
       "Comedian                                      0.512457\n",
       "Name: funny_rate, Length: 68, dtype: float64"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# redo the previous groupby\n",
    "ted_top_occupations.groupby('speaker_occupation').funny_rate.mean().sort_values()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lessons:\n",
    "\n",
    "1. Check your assumptions about your data\n",
    "2. Check whether your results are reasonable\n",
    "3. Take advantage of the fact that pandas operations often output a DataFrame or a Series\n",
    "4. Watch out for small sample sizes\n",
    "5. Consider the impact of missing data\n",
    "6. Data scientists are hilarious"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
